<!DOCTYPE html>
<html lang="<%= ::I18n.locale %>" class="no-js loading-custom-elements">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="color-scheme" content="light dark">
    <title><%= render_alchemy_title %></title>
    <link rel="shortcut icon" href="<%= asset_path('alchemy/favicon.ico') %>">
    <link rel="preload" href="<%= asset_path("alchemy/icons-sprite.svg") %>" as="image" type="<%= Mime::Type.lookup_by_extension(:svg) %>" crossorigin>
    <%= csrf_meta_tag %>
    <meta name="robots" content="noindex">
    <meta name="turbo-prefetch" content="false">
    <meta name="turbo-cache-control" content="no-cache">
    <%= stylesheet_link_tag('alchemy/theme', media: 'screen', 'data-turbo-track' => true) %>
    <%= stylesheet_link_tag('alchemy/admin', media: 'screen', 'data-turbo-track' => true) %>
    <%= stylesheet_link_tag('alchemy/admin/print', media: 'print', 'data-turbo-track' => true) %>
    <% Alchemy.config.admin_stylesheets.each do |stylesheet| %>
      <%= stylesheet_link_tag(stylesheet, 'data-turbo-track' => true) %>
    <% end %>
    <%= yield :stylesheets %>
    <script>
      // Global Alchemy JavaScript object.
      var Alchemy = {};
      // Store regular expression for external link url matching.
      Alchemy.link_url_regexp = <%= link_url_regexp.inspect %>;
      // JS translations
      <%= alchemy_admin_js_translations %>
    </script>
    <%= render 'alchemy/admin/tinymce/setup' %>
    <%= render 'alchemy/admin/partials/routes' %>
    <%= javascript_importmap_tags("alchemy_admin", importmap: Alchemy.importmap) %>
    <% Alchemy.config.admin_js_imports.each do |path| %>
      <script type="module">
        import "<%= path %>"
      </script>
    <% end %>
    <%= yield :javascript_includes %>
  </head>
  <%= content_tag :body, id: 'alchemy',
    class: alchemy_body_class,
    style: cookies["alchemy-elements-window-width"] && "--elements-window-width: #{cookies["alchemy-elements-window-width"]}px" do %>
    <noscript>
      <h1><%= Alchemy.t(:javascript_disabled_headline) %></h1>
      <p><%= Alchemy.t(:javascript_disabled_text) %></p>
    </noscript>
    <alchemy-overlay text="<%= Alchemy.t(:please_wait) %>"></alchemy-overlay>
    <div id="left_menu">
      <div id="main_navi">
        <% sorted_alchemy_modules.each do |alchemy_module| %>
          <%= alchemy_main_navigation_entry(alchemy_module) %>
        <% end %>
        <%= yield(:alchemy_main_navigation) %>
      </div>

      <div id="logout">
        <div class="main_navi_entry">
          <% if current_alchemy_user %>
            <%= link_to_dialog(
              %(
                #{render_icon('logout-box-r', class: 'module')}
                <label>#{Alchemy.t(:leave)}</label>
              ).html_safe,
              alchemy.leave_admin_path, {
                size: "300x155",
                title: Alchemy.t("Leave Alchemy")
            }, {'data-alchemy-hotkey' => 'alt+q'}) %>
          <% else %>
            <%= link_to(alchemy.root_path) do %>
              <%= render_icon "logout-box-r", size: "lg" %>
              <label><%= Alchemy.t(:leave) %></label>
            <% end %>
          <% end %>
        </div>
      </div>
    </div>
    <% if current_alchemy_user %>
    <div id="top_menu">
      <div id="header">
        <% if @locked_pages.present? %>
          <div id="locked_pages">
            <%= render partial: 'alchemy/admin/pages/locked_page', collection: @locked_pages %>
          </div>
        <% end %>
        <div id="user_info">
          <%= current_alchemy_user_name %>
          <%= render Alchemy::Admin::LocaleSelect.new %>
        </div>
      </div>
      <div id="toolbar">
        <%= yield(:toolbar) %>
      </div>
    </div>
    <% end %>
    <%= render 'alchemy/admin/partials/flash_notices' %>
    <div id="main_content">
      <%= yield %>
    </div>
    <%= render 'alchemy/admin/uploader/setup' %>
    <%= yield(:javascripts) %>
  <% end %>
</html>
